package cn.edu.scau.cmi.linhuanrui.singleton;

import cn.edu.scau.cmi.linhuanrui.singleton.Marshal;

public class Marshal {
	private static Marshal[] marshal = null;
	private static int num = 0;
	private String name = null;

	private Marshal(String name) {
		this.name = name;
	}

	public static Marshal getInstance(String name) {
		if (num == 0) {
			marshal = new Marshal[10];
		}
		for (int i = 0; i < num; i++) {
			if (name.equals(marshal[i].getName()))
				return marshal[i];
		}
		if (num < 10 && !name.equals(null))
			marshal[num++] = new Marshal(name);
		else
			return null;
		return marshal[num - 1];
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public static int getNum() {
		return num;
	}

	public void setNum(int num) {
		Marshal.num = num;
	}
}
